package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Activityprizes;
import org.hxyjs.entity.Activityprizes;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.ActivityprizesService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller
@RequestMapping("/activityprizesController")
public class ActivityprizesController {
	@Resource
	ActivityprizesService activityprizesService;
	@RequestMapping("/getAllActivityprizes")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Activityprizes> getAllActivityprizes() throws Exception {
    	System.out.println("查询全部活动奖品");
		return activityprizesService.getAllActivityprizess();
    }

	@RequestMapping("/deleteActivityprizesByApno/{apno}")
	@ResponseBody
    public DTO<Activityprizes> deleteActivityprizesByApno(@PathVariable("apno") String apno) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(apno+"删除活动奖品");
    	return activityprizesService.deleteActivityprizesByApno(apno);
    }

	@RequestMapping("/updateActivityprizesByApno")
	@ResponseBody
	public DTO<Activityprizes> updateActivityprizesByApno(@RequestBody Activityprizes activityprizes) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改活动奖品");
		return activityprizesService.updateActivityprizesByApno(activityprizes);
	}


	@RequestMapping("/addActivityprizes")
	@ResponseBody
	public DTO<Activityprizes> addActivityprizes(@RequestBody Activityprizes activityprizes) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加活动奖品");
		System.out.println(activityprizes);
 		return activityprizesService.addActivityprizes(activityprizes);
	}
	@RequestMapping("/getActivityprizesByPage")
	@ResponseBody
	public DTO<Activityprizes> getActivityprizesByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页活动奖品");
		return activityprizesService.getActivityprizesByPage(pageInfo);
	}


}